--- mag.c	2010-09-13 13:56:43.000000000 -0400
+++ mag.c.fixed	2021-12-07 23:23:49.729231259 -0500
@@ -174,7 +174,6 @@
       ximage=XGetImage(display,root,x-sx,y-sy,width/zoom,height/zoom,AllPlanes,ZPixmap);
       // fprintf(stderr,"XGetImage returns:%d\n",(int)ximage);
       // XPutImage(display,main_win,the_GC,ximage,0,0,0,0,width,height);
-      XDestroyImage(ximage);
       for(sx=0;sx<width/zoom;sx++) {
         for(sy=0;sy<height/zoom;sy++) {
           pix=XGetPixel(ximage,sx,sy);
@@ -186,6 +185,7 @@
           }
         }
       }
+      XDestroyImage(ximage);
       XFlush(display);
     } else {
       usleep(30000);
